using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Framework;
using HeroldIT.Dnn.JQuery.UI;
using HeroldIT.Dnn.Modules.WebControls;

namespace HeroldIT.Dnn.Modules.News
{
    /// <summary>
    /// Summary description for NewsEdit
    /// </summary>
    public partial class NewsEdit : Views.Edit
    {
        protected override void OnLoad(EventArgs e)
        {
            this.shcGlobalEntryParams.Text = this.GetString("shcGlobalEntryParams.Text");
            this.shcLanguageSpecific.Text = this.GetString("shcLanguageSpecific.Text");
            this.shcImages.Text = this.GetString("shcImages.Text");
            this.btnNewCategory.Text = this.GetString("btnNewCategory.Text");

            ((TextBox)this.txtDisplayOrder).Attributes["onkeypress"] = UIHelper.GetLimitCharsHandlerScript(this.Page, "0123456789-");

            string languageName = ((PageBase)this.Page).PageCulture.TwoLetterISOLanguageName;

            ((DatePicker)this.txtDisplayDate).Locale = languageName;
            ((DatePicker)this.txtPublishOn).Locale = languageName;
            ((DatePicker)this.txtPublishUntil).Locale = languageName;

            ((LinkButton)this.btnDelete).OnClientClick = "return window.confirm(\"" + this.GetString("msgReallyDelete.Text") + "\")";
            ((LinkButton)this.btnDeleteLocale).OnClientClick = "return window.confirm(\""
                                                                + this.GetString("msgReallyDeleteLocale.Text") + "\")";
            ((ImageBrowser)this.txtTeaserImageUrl).DataBind();
            ((ImageBrowser)this.txtDetailImageUrl).DataBind();

            if (this.DisplayLocales.Count <= 1)
            {
                this.shcLanguageSpecific.Visible = false;
                this.trLocale.Style[HtmlTextWriterStyle.Display] = "none";
                this.trLocaleIsHidden.Style[HtmlTextWriterStyle.Display] = "none";
                this.trIsDefaultLocale.Style[HtmlTextWriterStyle.Display] = "none";
            }

            JQuery.JQuery.RegisterJQuery(this.Page);
            JQuery.JQuery.RegisterJQueryOnDocumentReadyBlock(this.Page, "updateTeaserControls()");
            JQuery.JQuery.RegisterJQueryOnDocumentReadyBlock(this.Page, "$('" + JQuery.JQuery.JQueryClientID((Control)this.chkUseDetailImageForTeaser) + "').change(function(){updateTeaserControls()})");

            base.OnLoad(e);
        }

        protected override void OnPreRender(EventArgs e)
        {
            this.litNoCategories.DataBind();

            base.OnPreRender(e);
        }
    }
}